#ifdef __cplusplus
extern "C" {
#endif
	#ifndef __USART1_H
	#define __USART1_H
	#include "stm32f4xx.h"
	#define UR1ToROS
	
	#define strBuffLength 2048
	#define MALLOC_CAP_DEFAULT          (1<<12) ///< Memory can be returned in a non-capability-specific memory allocation (e.g. malloc(), calloc()) call
	
	typedef enum {
		UART_DATA,              /*!< UART data event*/
		UART_BREAK,             /*!< UART break event*/
		UART_BUFFER_FULL,       /*!< UART RX buffer full event*/
		UART_FIFO_OVF,          /*!< UART FIFO overflow event*/
		UART_FRAME_ERR,         /*!< UART RX frame error event*/
		UART_PARITY_ERR,        /*!< UART RX parity event*/
		UART_DATA_BREAK,        /*!< UART TX data and break event*/
		UART_PATTERN_DET,       /*!< UART pattern detected */
		#if SOC_UART_SUPPORT_WAKEUP_INT
			UART_WAKEUP,            /*!< UART wakeup event */
		#endif
		UART_EVENT_MAX,         /*!< UART event max index*/
	} uart_event_type_t;
	/**
	 * @brief Event structure used in UART event queue
	 */
	typedef struct {
		uart_event_type_t type; /*!< UART event type */
		uint32_t size;          /*!< UART data size for UART_DATA event*/
		uint8_t timeout_flag;      /*!< UART data read timeout flag for UART_DATA event (no new data received during configured RX TOUT)*/
								/*!< If the event is caused by FIFO-full interrupt, then there will be no event with the timeout flag before the next byte coming.*/
	} uart_event_t;
	
	void USART1_Init(uint32_t baudrate);
	void u1SetDmaSendOver_func(void (* const send)(void));
	void u1SetDmaReadOver_func(uint8_t (* const read)(void *pReadOver_t));
	void u1TaskSetDmaSendOver_func(void (* const send)(void));
	void u1SetDmaRead_func(uint8_t(*dmaRead_func_t)(uint8_t *buff_t2,uint32_t u2Size));
	void u1IT_IDLE_ReadEnable(void);
	void u1IT_IDLE_ReadDisable(void);
	void u1DataFrame_Send(uint8_t *buf, uint16_t length);
	void u1_printf(char* fmt,...); 
	#endif
#ifdef __cplusplus
}
#endif
